// pages/security-pass/security-pass.js
var app = getApp();
var com = require('../../common.js')
Page({
  data: {
    oldPassword: '',
    password: '',
    onpassword: ''
  },
  onLoad: function(options) {},
  onReady: function() {},
  onShow: function() {},
  onHide: function() {},
  onUnload: function() {},
  onPullDownRefresh: function() {},
  onReachBottom: function() {},
  bingInput(e) {
    var _this = this,
      id = e.currentTarget.id,
      ぃ = e.detail.value
    if (id == 1) {
      _this.setData({
        oldPassword: ぃ
      })
    } else if (id == 2) {
      _this.setData({
        password: ぃ
      })
    } else {
      if (ぃ == _this.data.password) {
        _this.setData({
          onpassword: ぃ
        })
      } else {
        wx.showToast({
          title: '密码输入不一致',
          icon: 'none'
        })
      }

    }
  },
  onShareAppMessag: function() {
    var _this = this
    com.link(app.link.infocenter_password, {
      password: _this.data.password,
      old: _this.data.oldPassword
    }, function(res) {
      console.log(res)
      if (res.data.state) {
        wx.showToast({
          title: '修改成功',
          icon: 'success'
        })
        setTimeout(() => {
          wx.navigateBack({
            delta: 1
          })
        }, 1500)
      } else {
        wx.showToast({
          title: res.data.message,
          icon: 'none'
        })
      }
    })
  }
})